<template>
  <div>
    <el-row>
      <el-col :md="24">
        <div class="recommend">推荐阅读</div>
      </el-col>
      <el-col :md="24">
        <ul>
          <li class="recommend-item" v-for="item in recommend_post_list">
            <i class="fa fa-file-o text-[#ccc]"></i>
            <nuxt-link :to="'/post/detail/' + item.id" class="pl-10px no-underline text-[#333] hover:underline">{{
              item.post_title
            }}</nuxt-link>
          </li>
        </ul>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { get_post_relation } from '~/api';

const props = defineProps({
  post_id: {
    type: Number,
    required: true,
  },
});

const { data: recommend_post_list, pending } = await useAsyncData('recommend-post-list', () => get_post_relation(props.post_id), {
  server: true,
});

if (!pending.value && !recommend_post_list.value) {
  recommend_post_list.value = [];
}
</script>

<style scoped>
.recommend {
  background: url(https://www.dzklawyer.com/themes/ls/static/images/arrow_right.png) no-repeat left;
  padding-left: 32px;
  font-size: 18px;
  margin-top: 50px;
  margin-bottom: 10px;
  font-weight: 500;
  line-height: 1.1;
}
.recommend-item {
  border-bottom: 1px solid #ccc;
  padding: 10px;
}
</style>
